Omplus.base.define(Omplus.controllers.Controller, {
    omplusName:"paymentsController"
});

Omplus.models.PaymentSearchModelProto = Omplus.base.extend(Omplus.models.Object, {
    omplusType:"PaymentSearchModelProto",
    value:{
        "banner":{
            omplusType:"String"
        },
        "method":{
            omplusType:"String"
        },
        "min_amount":{
            omplusType:"String"
        },
        "name":{
            omplusType:"String"
        },
        "max_amount":{
            omplusType:"String"
        },
        deposit_type_id:{
            omplusType:"Number"
        }
    }
});


Omplus.base.define(Omplus.models.Model, {
    omplusName:"orderingPaymentsModel",
    controller:"paymentsController",
    value:{
        deposit_types:{
            omplusType:"Array",
            omplusProto:"PaymentSearchModelProto"
        },
        order:{
            omplusType:"Array",
            omplusProto:"String"
        }
    },
    actions:[
        {
            omplusType:"Get",
            omplusName:"getPaymentsForOrdering",
            proxy:{
                omplusType:"AjaxProxy"
            },
            responseModel:"orderingPaymentsModel",
            requestModel:"orderingPaymentsModel"
        },
        {
            omplusType:"Get",
            omplusName:"setPaymentsForOrdering",
            proxy:{
                omplusType:"AjaxProxy"
            },
            responseModel:"orderingPaymentsModel",
            requestModel:"orderingPaymentsModel"
        }
    ]
});

Omplus.base.define(Omplus.views.Panel, {
    omplusName:"paymentsPanel",
    controller:"paymentsController",
    renderTo:"managements",
    models:{
    },
    components:[
        {
            omplusType:"TabPanel",
            omplusName:"orderPaymentsPanel",
            layout:{
                omplusType:"HorizontalLayout"
            },
            controller:"languageController",
            model:"Assets.list.order_label.localValue",
            components:[
                {
                    omplusType:"Button",
                    omplusName:"getPaymentsForOrderingButton",
                    model:"Assets.list.label_search_button.localValue",
                    controller:"languageController",
                    click:function () {
                        Omplus.globals.getObject("orderingPaymentsModel").getAction("getPaymentsForOrdering").run();
                    }
                },
                {
                    omplusType:"Button",
                    omplusName:"savePaymentsForOrderingButton",
                    model:"Assets.list.label_save_button.localValue",
                    controller:"languageController",
                    click:function () {
                        var array = Omplus.globals.getObject("SortablePayments").toArray();
                        Omplus.globals.getObject("orderingPaymentsModel.order").setValue(array);
                        Omplus.globals.getObject("orderingPaymentsModel").getAction("setPaymentsForOrdering").run();
                    }
                },
                {
                    omplusType:"SortableList",
                    omplusName:"SortablePayments",
                    renderTo:"orderPaymentsPanel",
                    model:"orderingPaymentsModel.deposit_types",
                    controller:"paymentsController",
                    forDisplay:"name",
                    forId:"deposit_type_id"
                }
            ]
        }
    ],
    layout:{
        omplusType:"TabLayout"
    },
    showEffect:{
        name:"explode",
        time:300
    },
    hideEffect:{
        name:"explode",
        time:300
    }
});